package leetcode.N201_N300;

import java.util.ArrayList;
import java.util.List;

public class N232 {

    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();

        myQueue.push(1);
        myQueue.push(2);
        myQueue.peek();
        myQueue.pop();
        myQueue.empty();
    }


}

class MyQueue {

    /** Initialize your data structure here. */
    int head = 0;
    int tail = 0;
    List<Integer> list = new ArrayList<>();

    public MyQueue() {

    }

    /** Push element x to the back of queue. */
    public void push(int x) {
        list.add(tail++, x);
    }

    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
        return list.get(head++);
    }

    /** Get the front element. */
    public int peek() {
        return list.get(head);
    }

    /** Returns whether the queue is empty. */
    public boolean empty() {
        return head == tail;
    }
}
